<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:head>

	<style type="text/css">
.ui-layout-north {
	z-index: 20 !important;
	overflow: visible !important;;
}

.ui-layout-north .ui-layout-unit-content {
	overflow: visible !important;
}

.ui-widget {
	font-size: 10px !important;
}

.size {
	width: 550px;
	position: relative;
	left: 30%;
	top: 10%;
}

.centro {
	top: 50%
}

.tabela {
	width: 750px;
}
</style>


	<title>Cadastro de Determinação</title>
</h:head>

<h:body>

	<ui:decorate template="/templateBase.xhtml">

		<ui:define name="center">
			<p:growl id="growl" life="3000" autoUpdate="true" />
			<h:form prependId="true" id="formCadastroDeterminacao">
				<br />
				<br />
				<br />
				<br />
				<p:panel header="Cadastro de Determinação" styleClass="size"
					toggleable="true"
					footer="SIGLAS - Sistema de Gerenciamento de Laboratório de Análise de Solo">

					<br />

					<h:panelGrid columns="3">
						<h:outputText value="Descrição: " />
						<p:inputText size="50"
							value="#{DeterminacaoBacking.determinacaoSalvar.descricao}"
							required="true"
							requiredMessage="Informe a descrição do elemento!" />
						<p:commandButton icon="ui-icon-search" oncomplete="dlg.show()"
							actionListener="#{DeterminacaoBacking.criarListaDeterminacao}"
							update=":formPesquisaDeterminacao:tabelaDeterminacao"
							process="@all" immediate="true" />
						<h:outputText value="Tipo de Determinação" />

						<p:selectOneMenu effect="fade"
							value="#{DeterminacaoBacking.tipoDeterminacaoSelecionada}"
							required="true" requiredMessage="Informe o tipo de determinação!">
							<f:selectItem itemDisabled="true" itemLabel="Selecione" />
							<f:selectItems
								value="#{DeterminacaoBacking.listaTipoDeterminacao}" />
						</p:selectOneMenu>

					</h:panelGrid>
					<br />

					<div align="center">
						<h:panelGrid columns="4">
							<p:commandButton value="Salvar" ajax="false"
								actionListener="#{DeterminacaoBacking.salvar}"
								update=":formCadastroDeterminacao" icon="ui-icon-disk" />
							<p:commandButton value="Cancelar"
								actionListener="#{DeterminacaoBacking.reset}"
								update=":formCadastroDeterminacao" icon="ui-icon-cancel" />
						</h:panelGrid>
					</div>
				</p:panel>
			</h:form>

			<h:form prependId="false" id="formPesquisaDeterminacao">
				<p:dialog id="pesquisaDeterminacao" widgetVar="dlg" appendToBody="true" modal="true"
					header="Pesquisar Determinacao" closable="true" height="400"
					width="500" resizable="false" showEffect="clip" hideEffect="clip">

					<p:dataTable var="d"
						value="#{DeterminacaoBacking.listaDeterminacao}" rows="10"
						widgetVar="DeterminacaoTabela" paginator="true"
						id="tabelaDeterminacao"
						emptyMessage="Nenhum registro foi encontrado, tente novamente!">
						<h:outputText value="Determinações cadastradas" />

						<p:column headerText="Descrição" filterBy="#{d.descricao}">
							<h:outputText value="#{d.descricao}" />
						</p:column>

						<p:column headerText="Tipo de Determinação"
							filterBy="#{d.tipoDeterminacao.descricao}">
							<h:outputText value="#{d.tipoDeterminacao.descricao}" />
						</p:column>

						<p:column>
							<f:facet name="header">
								<h:outputText value="Ações" />
							</f:facet>

							<p:commandButton value="Alterar" onclick="dlg.hide()"
								ajax="false" icon="ui-icon-pencil"
								update=":formCadastroDeterminacao"
								action="#{DeterminacaoBacking.preparaAlteracao}">
								<f:setPropertyActionListener
									target="#{DeterminacaoBacking.determinacaoSelecionada}"
									value="#{d}" />
							</p:commandButton>
							<p:commandButton value="Excluir" icon="ui-icon-trash"
								update=":formPesquisaDeterminacao:tabelaDeterminacao"
								oncomplete="dlgDelete.show()">
								<f:setPropertyActionListener
									target="#{DeterminacaoBacking.determinacaoSelecionada}"
									value="#{d}" />
							</p:commandButton>
						</p:column>
					</p:dataTable>
				</p:dialog>

				<p:dialog id="confirmaDelete" widgetVar="dlgDelete"
					header="Excluir registro" width="230" resizable="false"
					showEffect="clip" hideEffect="clip" closable="true">
					<br />
					<div align="center">
						<h:outputText value="Deseja realmente excluir?" />
						<br /> <br />
						<p:commandButton value="Sim"
							action="#{DeterminacaoBacking.delete}"
							onsuccess="dlgDelete.hide()"
							update=":formPesquisaDeterminacao:tabelaDeterminacao"
							process="@all" immediate="true" />
						<p:commandButton value="Não" onclick="dlgDelete.hide()" />
					</div>
				</p:dialog>
			</h:form>


		</ui:define>
	</ui:decorate>
</h:body>
</html>